select * from ( select folder_parent, folder_name, count(*) kount from oit_folder where folder_type in ('site','cabinet','folder') and mark_for_delete = 0 group by folder_parent, folder_name) t1 where t1.kount > 1 ------------------ --select 'Duplicate Folder Check ...' go select * from ( select folder_parent, folder_name, count(*) kount from oit_folder where folder_type in ('site','cabinet','folder') and mark_for_delete = 0 group by folder_parent, folder_name) t1 where t1.kount > 1 go --select 'Files in Template Folder ...' go select rec_id from oit_file where folder_Rec_id in (select rec_id from oit_folder where folder_type in ('template','template_group')) go select rec_id from oit_file where old_folder_Rec_id in (select rec_id from oit_folder where folder_type in ('template','template_group')) go select rec_id from oit_folder where folder_type = 'FOLDER' and folder_parent in (select rec_id from oit_folder where folder_type in ('template','template_group'))